package operatori;

import arbori.Nod;

/**
 * 
 * @author Sorica Alexandra
 * @date 18.04.2011
 * @version 1.0
 * This class is root-class for basic arithmetical operations.
 *
 */

public abstract class Operator extends Nod{
	
	/**
	 * 
	 * @return result between the left and right nodes
	 */
	
	public double calcul(){
		double r=0.0;
			if(super.ns==null||super.nd==null)
				System.out.println("get lost");else{
					double nsVal=ns.calcul();
					double ndVal=nd.calcul();
					r=calcul(nsVal, ndVal);
				}
			return r;
		}
		public abstract double calcul(double V1, double V2);
		public abstract String concat(String V1, String V2);
	
		/**
		 * @return String representation of the operation.
		 */
		
		public String toString(){
			String s=null;
			if(super.ns==null||super.nd==null)
				System.out.println("get lost");
			else
				s=concat(super.ns.toString(),super.nd.toString());
			return s;
		}
	}